import { io } from './io'

export const queryMessageTypeList = () =>
    io<Api.Content.MessageTypeList>({
        url: '/api/v1/messagecenter/messagetype/list',
        method: 'GET'
    })

export const createMessageType = (data: Api.Content.MessageTypeCreateParams) =>
    io<{
        success: boolean
    }>({
        url: '/api/v1/messagecenter/messagetype/add',
        method: 'POST',
        data
    })

export const updateMessageType = (id: Api.Content.MessageType['id'], data: Api.Content.MessageTypeCreateParams) =>
    io<{
        success: boolean
    }>({
        url: `/api/v1/messagecenter/messagetype/${id}`,
        method: 'PUT',
        data
    })

export const queryMessageList = (params: Api.Content.MessageSearchParams) =>
    io<Api.Content.MessageList>({
        url: '/api/v1/messagecenter/message/list',
        method: 'GET',
        params
    })

export const createMessage = (data: Api.Content.MessageCreateParams) =>
    io<{
        success: boolean
    }>({
        url: '/api/v1/messagecenter/message/add',
        method: 'POST',
        data
    })

export const queryMessageDetail = (id: Api.Content.Message['id']) =>
    io<Api.Content.Message>({
        url: `/api/v1/messagecenter/message/info/${id}`,
        method: 'GET'
    })

export const updateMessage = (id: Api.Content.Message['id'], data: Api.Content.MessageCreateParams) =>
    io<{
        success: boolean
    }>({
        url: `/api/v1/messagecenter/message/${id}`,
        method: 'PUT',
        data
    })

export const delMessage = (id: Api.Content.Message['id']) =>
    io<{
        success: boolean
    }>({
        url: `/api/v1/messagecenter/message/${id}`,
        method: 'DELETE'
    })

export const createQa = (data: Api.Content.QaCreateParams) =>
    io<{
        success: boolean
    }>({
        url: '/api/v1/messagecenter/hotquestion/add',
        method: 'POST',
        data
    })

export const updateQa = (id: Api.Content.Qa['id'], data: Api.Content.QaCreateParams) =>
    io<{
        success: boolean
    }>({
        url: `/api/v1/messagecenter/hotquestion/${id}`,
        method: 'PUT',
        data
    })

export const queryQaList = (params: Api.Content.QaSearchParams) =>
    io<Api.Content.QaList>({
        url: '/api/v1/messagecenter/hotquestion/list',
        method: 'GET',
        params
    })

export const queryQaDetail = (id: Api.Content.Qa['id']) =>
    io<Api.Content.Qa>({
        url: `/api/v1/messagecenter/hotquestion/info/${id}`,
        method: 'GET'
    })

export const delQa = (id: Api.Content.Qa['id']) =>
    io<{
        success: boolean
    }>({
        url: `/api/v1/messagecenter/hotquestion/${id}`,
        method: 'DELETE'
    })

export const createAd = (data: Api.Content.AdCreateParams) =>
    io<{
        success: boolean
    }>({
        url: '/api/v1/messagecenter/advert/add',
        method: 'POST',
        data
    })

export const updateAd = (id: Api.Content.Ad['id'], data: Api.Content.AdCreateParams) =>
    io<{
        success: boolean
    }>({
        url: `/api/v1/messagecenter/advert/${id}`,
        method: 'PUT',
        data
    })

export const queryAdList = (params: Api.Content.AdSearchParams) =>
    io<Api.Content.AdList>({
        url: '/api/v1/messagecenter/advert/list',
        method: 'GET',
        params
    })

export const queryAdDetail = (id: Api.Content.Ad['id']) =>
    io<Api.Content.Ad>({
        url: `/api/v1/messagecenter/advert/info/${id}`,
        method: 'GET'
    })

export const delAd = (id: Api.Content.Ad['id']) =>
    io<{
        success: boolean
    }>({
        url: `/api/v1/messagecenter/advert/${id}`,
        method: 'DELETE'
    })
